﻿using System;
using System.Linq;
using Olympic_email_to_future.Module;
using Olympic_email_to_future.BLLFactory;
using Olympic_email_to_future.IBLL;

namespace FutureMeWeb.FutureMe_Admin
{
    public partial class login : System.Web.UI.Page
    {
        public UserInfo userinfo = new UserInfo();
        public IUserBLL userbll = BusinessFactory.CreateUserBLL();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Login_Click(object sender, EventArgs e)
        {
            userinfo.userMailAddress = email_login.Text;
            userinfo.userPassword = password.Text;
            UserInfo users = userbll.getUser(userinfo);
            if (userbll.login(userinfo))
            {
                int role = users.userRole;
                if (role == 0)
                {
                    Response.Write("<script>alert('您不是管理员');</script>");
                }
                else
                {
                    Session.Add("User", userinfo);
                    Response.Redirect("index.aspx");
                }

            }
            else
            {
                Response.Write("<script>alert('用户名或者密码有误');</script>");
            }
        }

    }
}